package com.springcloud.util.model;

/**
 * @Description: TODO
 * @Create by: 123
 * @Date: 2021/11/22 16:46
 */


public class NumberUtils {
    public static Float parseNumber(String value) {
        try {
            return Float.valueOf(value);
        } catch (Exception e) {
           // e.printStackTrace();
        }
        return null;
    }

    public static float parseNumber(String value, Float defaultValue) {
        try {
            return Float.valueOf(value);
        } catch (Exception e) {
            //e.printStackTrace();
        }
        return defaultValue;
    }

    public static int getNumberFormHex(String hex) {
        try {
            String trim = hex.trim();
            return Integer.valueOf(trim, 16);
        } catch (Exception e) {
           // e.printStackTrace();
        }
        return 255;
    }

    public static int parseInt(String numStr, int defaultValue) {
        try {
            return Integer.valueOf(numStr);
        } catch (Exception e) {
           // e.printStackTrace();
        }
        return defaultValue;
    }
}
